package com.qf.collection.generic;

import java.util.Iterator;
import java.util.Random;

public class RandomIntegerIterator implements Iterator<Integer>,Iterable<Integer> {

    private int count;

    private int index;

    public RandomIntegerIterator(int count){
        this.count = count;
    }

    @Override
    public boolean hasNext() {
        return index<count;
    }

    @Override
    public Integer next() {
        int i = new Random().nextInt(1000);
        index++;
        return  i;
    }

    @Override
    public Iterator<Integer> iterator() {
        return this;
    }
}
